{extend name="public:_base" /}
{block name="css"}
{CSS href="__STATIC__/w/admin_base.css" /}
{CSS href="__STATIC__/w/layui.css" /}
{CSS href="__STATIC__/w/divtable.css" /}
{/block}

{block name="js"}
{js href='__STATIC__/w/jquery1110min.js' /}
{js href='__STATIC__/w/layui.js' /}
{js href='__STATIC__/w/ajax_file_upload.js' /}
{js href='__STATIC__/admin/hui/lib/layer/2.4/layer.js' /}
{/block}

{block name="main"}

<nav class="breadcrumb"><i class="Hui-iconfont">&#xe67f;</i> 首页 <span class="c-gray en">&gt;</span> 二维码/转化链接  <a class="btn radius btn-success radius r" style="line-height:1.6em;margin-top:3px"
                                              href="javascript:location.replace(location.href);" title="刷新"><i
        class="Hui-iconfont">&#xe68f;</i></a></nav>


<div class="layui-form-cont">

    <div class="layui-tab" lay-filter="docDemoTabBrief">

        <div class="layui-tab-nav">
            <div class="layui-tab-left">
                <a class="layui-btn radius layui-btn-normal" href="{:url(\''.\\think\\Request::instance()->controller().'/qrcodeAdd')}">
                    <i class="Hui-iconfont">&#xe600;</i> 增加二维码
                </a>
            </div>

            <div class="layui-tab-right layui-tab-brief">
                <ul class="layui-tab-title">
                    <li {eq name="type" value="list"}class="layui-this"{/eq} >
                        <a href="{:url(\''.\\think\\Request::instance()->controller().'/qrcode',['type'=>'list'])}">二维码列表</a>
                    </li>

                    <li {eq name="type" value="statistics"}class="layui-this"{/eq}>
                        <a href="{:url(\''.\\think\\Request::instance()->controller().'/qrcode',['type'=>'statistics'])}">二维码扫描统计</a>
                    </li>
                </ul>
            </div>
        </div>

        <div class="layui-tab-content layui-new-table">
            {switch name="type"}
            {case value="list"}

            <table class="layui-table" lay-skin="line">
                <thead>
                <tr>
                    <th>二维码</th>
                    <th>场景名称</th>
                    <th>对应关键字</th>
                    <th>类型</th>
                    <th>到期时间</th>
                    <th>短链接</th>
                    <th>操作</th>
                </tr>
                </thead>
                <tbody>
                {volist name="data" id="vo"}
                <tr>
                    <td><div  style="padding: 1px; border: #e6e6e6 solid 1px; width:50px; float: left; ">
                        <img  class="form_logo" src="{$vo.qrcode_url}" width="50" height="50"  onmouseover="layer_tips=layer.tips('<img src={$vo.qrcode_url} class=\'layer_tips_img\'>',this,{tips: [1, '#fff']});" onmouseout="layer.close(layer_tips);">
                    </div></td>
                    <td>{$vo.scene_name}</td>
                    <td>{$vo.keyword}</td>
                    <td>{if condition="$vo.qr_type eq '0'"}临时
                        {else /} 永久
                        {/if}</td>
                    <td>{if condition="$vo.qr_type eq '0'"}{$vo.create_time}
                        {else /} 长期有效
                        {/if}</td>
                    <td>
                        {$vo.short_url}
                    </td>
                    <td>
                        <a class="rha-bt-a" href="javascript:;" onclick="delQrcode('{$vo.id}')">删除</a>
                        <a target="_blank" href="{$vo.short_url}" class="rha-bt-a">查看</a>
                    </td>
                </tr>
                {/volist}
                </tbody>
            </table>
            {$data->render()}
            {/case}
            {case value="statistics"}
            <table class="layui-table" lay-skin="line">
                <thead>
                <tr>
                    <th>二维码</th>
                    <th>场景名称</th>
                    <th>触发关键字</th>
                    <th>类型</th>
                    <th>被扫总数</th>
                    <th>粉丝增加</th>
                    <th>操作</th>
                </tr>
                </thead>
                <tbody>
                {volist name="data" id="vo"}
                <tr>
                    <td><div  style="padding: 1px; border: #e6e6e6 solid 1px; width:50px; float: left; ">
                        <img class="form_logo" src="{$vo.qrcode_url}" width="50" height="50" onmouseover="layer_tips=layer.tips('<img src={$vo.qrcode_url} class=\'layer_tips_img\'>',this,{tips: [1, '#fff']});" onmouseout="layer.close(layer_tips);">
                    </div></td>
                    <td>{$vo.scene_name}</td>
                    <td>{$vo.keyword}</td>
                    <td>{if condition="$vo.qr_type eq '0'"}临时
                        {else /} 永久
                        {/if}</td>
                    <td>{$vo.scan_count}</td>
                    <td>{$vo.gz_count}</td>
                    <td>
                        <a href="{:url('qrcode',['scene_id'=>$vo.scene_id,'type'=>'friend'])}" class="rha-bt-a">查看增加粉丝</a>
                    </td>
                </tr>
                {/volist}
                </tbody>
            </table>
            {$data->render()}
            {/case}
            {case value="friend"}
            <table class="layui-table" lay-skin="line">
                <thead>
                <tr>
                    <th>场景 ID</th>
                    <th>呢称</th>
                    <th>头像</th>
                    <th>扫码次数</th>
                    <th>扫码时间</th>
                </tr>
                </thead>
                <tbody>
                {volist name="data" id="vo"}
                <tr>
                    <td>{$vo.scene_id}</td>
                    <td>{$vo.nickname}</td>
                    <td><img height="38" width="38" style="border-radius: 3px;" src="{$vo.headimgurl}"  onmouseover="layer_tips=layer.tips('<img src={$vo.headimgurl} class=\'layer_tips_img\'>',this,{tips: [1, '#fff']});" onmouseout="layer.close(layer_tips);"></td>
                    <td>{$vo.scan_count}</td>
                    <td>{:date('Y-m-d H:s:i',$vo.create_time)}</td>
                </tr>
                {/volist}
                </tbody>
            </table>
            {$data->render()}
            {/case}
            {/switch}
        </div>
    </div>
</div>
    <script>
        function delQrcode(id) {
            layui.use('layer', function(){
                var layer = layui.layer;
                layer.confirm('你确定需要删除吗？', {
                    btn: ['是','不'] //按钮
                }, function(){
                    $.post("{:url('delQrcode')}",{'id':id},function (res) {
                        if(res.status==1){
                            layer.alert(res.msg,function (index) {
                                window.location.reload();
                                layer.close(index);
                            })

                        }else{
                            layer.alert(res.msg)
                        }
                    })
                }, function(){

                });
            });

        }
    </script>
{/block}